May, 20 2023

Assignment - Plotly using mtcars dataset

For this example we will try to show the previous analysis the relationship between MPG (Miles Per Gallon) and types of vehicle (automatic/ manual)

library(plotly)
library(webshot)
data(mtcars)
mtcars$cyl <- as.factor(mtcars$cyl)
p1 <- plot_ly(
  data = mtcars,
  y = ~mpg,
  x = ~hp,
  color = ~cyl
)

Plot Result

p1

Thank You